package com.lxit.video.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.lxit.video.bean.UserInfo;

public interface UserRepository extends JpaRepository<UserInfo, Integer>,UserDao {
	// 前台登录
	@Query("select u from UserInfo u where u.userPhone=:name and u.password=:password and u.userStatus=0 and u.uTypeId!=4")
	List<UserInfo> login(@Param("name") String name, @Param("password") String password);

	// 后台登录
	@Query("select u from UserInfo u where u.userPhone=:name and u.password=:password and u.userStatus=0 and u.uTypeId=4")
	List<UserInfo> admin_login(@Param("name") String name, @Param("password") String password);

	// 验证用户名的存在
	@Query("select count(1) from UserInfo u where u.userAlias=:name")
	int nameCount(@Param("name") String name);

	// 验证手机号码
	@Query("select count(1) from UserInfo u where u.userPhone=:phone")
	int phoneCount(@Param("phone") String name);
	
}
